Conversation
k0000k
approved these changes
May 27, 2025
Comment on lines
+39
to
+43
| count += diffDistance[i]/mid; | ||
| // 0으로 나누어 떨어진 경우 이미 휴게소가 1개 지어진 경우이므로 -1을 해준다. | ||
| if(diffDistance[i] % mid == 0) { | ||
| count--; | ||
| } |
Member
There was a problem hiding this comment.
엇ㅋㅋㅋ 저는 이거를 안될때까지 뺄셈하도록 했는데 나눗셈이라는 똑똑한 방법이...
Comment on lines
+25
to
+44
| public static void binary_search(int start, int end) { | ||
| while(start < end) { | ||
| int diff = arr[start] + arr[end]; | ||
| if(min > Math.abs(diff)) { | ||
| min = Math.abs(diff); | ||
| a = arr[start]; | ||
| b = arr[end]; | ||
| } | ||
| //두 용액의 합이 음수인 경우 | ||
| if(diff < 0) { | ||
| start++; | ||
| } | ||
| //두 용액의 합이 양수인 경우 | ||
| else if(diff > 0){ | ||
| end--; | ||
| } | ||
| else { | ||
| break; | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
아 세상에.. 이렇게하면 이분탐색으로 풀리는군요! 이걸 못떠올려서 절댓값 순으로 정렬해놓고 인접한 값들만 전부 비교했습니다... 😢
Comment on lines
+22
to
+24
| } else { | ||
| isFlag = true; | ||
| break; |
Member
There was a problem hiding this comment.
그냥 여기서 프린트하고 return; 해버리면 플래그를 안써도 깔끔하게 만들수 있습니다 !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ 문제번호 | 문제이름 | 난이도: 난이도 | 유형: 유형
📝 문제 설명
💡 풀이 설명